<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
	$(function() {
		$("#neworder").linkbutton({
			width : 80,
			height : 30,
			onClick : function() {			
				$.ajax({
					url:'CreateRejectOrder',
					type:'post',		
					success:function(flag){					
						if("-1" == flag){
							$.messager.alert('提示','请完成或取消当前订单');   
						}else{
							$('#tab').tabs('add', {
								title : '退货订单-'+ '${sessionScope.employee.eId}',
								content : "<iframe  frameborder='no' width='100%' height='100%' src= /superMarketManagementSystem/function/ordermanagement/rejectOrder.jsp></iframe>",
								closable : true,
							});
						}
					}
				})				
			}
		});
	//提交订单按钮
		$("#submit").linkbutton({			
			width : 80,
			height : 30,
			onClick:function(){
				$('#msg').dialog('open');			
			}
		});
	//取消订单按钮
		$("#cancel").linkbutton({
			width : 80,
			height : 30,
			onClick:function(){
				$.ajax({
					url:'DropRejectOrder',
					success:function(flag){
						if("0" == flag){
							$('#tab').tabs('close','退货订单-'+ '${sessionScope.employee.eId}');
							$("#vId").numberbox('clear');
							$("#notvip").prop("checked",true);
							$("#hid").hide();
							$("#bo").layout('collapse','south');
						}
					}
				})
			}
		});
		//是否为会员
		$("#isvip").click(function(){
			$("#hid").show();
			$("#vId").numberbox('clear');
		})
		
		$("#notvip").click(function(){
			$("#hid").hide();
			$("#bo").layout('collapse','south');
		})
		//会员信息确认按钮
		$("#vipbtn").linkbutton({
			onClick:function(){
				var vid = $("#vId").val();
				$("#vipinfo").datagrid({    
				    url:'vipinfo',   
				    queryParams:{"vId":vid},
				    columns:[[    
				        {field:'vId',title:'会员ID',width:100},    
				        {field:'vPoint',title:'积分',width:100},    
				        {field:'pitRate',title:'转换率',width:100,hidden:true}, 
				        {field:'vDiscount',title:'折扣率',width:100},    
				        {field:'vTme',title:'注册时间',width:200},  
				    ]]    
				}); 				
				$("#bo").layout('expand','south');
			}
		})
		//确认提交订单?
		$('#msg').dialog({    
		    title: '提示',    
		    width: 250,    
		    height: 160,    
		    closed: true,    
		    modal: true		
		});    
		
		//确定提交
		$('#okorder').linkbutton({
			onClick:function(){
				var vid = $("#vId").val();
				$.ajax({
					url:'SubmitRejectOrder',
					data:{"vId":vid},
					type:'post',
					success:function(oMoney){
						$.messager.alert('合计','退回金额：'+oMoney);					
						$('#tab').tabs('close','退货订单-'+ '${sessionScope.employee.eId}');
						$('#msg').dialog('close');	
						$("#vId").numberbox('clear');
						$("#notvip").prop("checked",true);
						$("#hid").hide();
						$("#bo").layout('collapse','south');
						$.ajax({
							url:'DropRejectOrder'
						})					
					}
				})
			}
		})
		
		//取消提交
		$('#cancelorder').linkbutton({
			onClick:function(){
				$('#msg').dialog('close');	
			}
		})

	})
</script>
<body class="easyui-layout" id = "bo">
	<div style="font-size: 14px; width: 200px" data-options="region:'west'" >
		<div style="margin: 20px">
			<!-- 新增订单按钮 -->
			<a id="neworder" href="#" style="margin-left: 18px;margin-top: 10px">新增订单</a> <br/><br/>
			<!-- 提交订单按钮 -->
			<a id="submit" href="#" style="margin-left: 18px;margin-top: 10px">提交订单</a> <br/><br/>
			<!-- 取消订单按钮 -->
			<a id="cancel" href="#" style="margin-left: 18px;margin-top: 10px">取消订单</a> <br/><br/>
			<!-- 是否为会员 -->
			<div style="margin-left: 18px;margin-top: 30px">	
			是否为会员&nbsp;&nbsp;<br/><br/>
			<input type="radio" id="isvip" name="vip">是
			<input type="radio" id="notvip" name="vip" checked="checked">否
			</div>
			<br /> 
			<div id="hid" style="display: none;margin-left:10px">			
			会员ID&nbsp;&nbsp;&nbsp;<br/><input id="vId" type="text" style="width: 120px; height: 25px" class="easyui-numberbox"><br /> 
			<a id="vipbtn" href="#" class="easyui-linkbutton" style="width: 80px">确认</a>  
			</div><br /><br /> 		
			<div id="msg" class="easyui-window" title="提示" style="width:600px;height:400px" data-options="modal:true">   
   				<p style="margin-top: 20px;margin-left: 40px;font-size: 15px"> 确认提交订单？</p> <br/>
   				<a href="#" id = 'okorder' class="easyui-linkbutton" data-options="iconCls:'icon-ok'" style="margin-left: 60px;margin-bottom: 20px">确定</a>  
				<a href="#" id = 'cancelorder' class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" style="margin-left: 20px;margin-bottom: 20px">取消</a>  
				
			</div>  				
		</div>
	</div>
	
	<div data-options="region:'center'">
		<div id="tab" class="easyui-tabs" data-options="fit:true"></div>				
		
	</div>
	
	<div data-options="region:'south',title:'会员信息',split:true,collapsed:true" style="height:100px;">
		<div id="showvip" class="easyui-tabs" data-options="fit:true">				
			<table id="vipinfo"></table>  			
		</div>
	</div>
	
	 

</body>
</html>